package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.OrderitemBoarding;
import com.ktgj.service.service.IOrderitemBoardingService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 值机订单明细Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/boarding")
public class OrderitemBoardingController extends BaseController
{
    @Autowired
    private IOrderitemBoardingService orderitemBoardingService;

    /**
     * 查询值机订单明细列表
     */
    @PreAuthorize(hasPermi = "service:boarding:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderitemBoarding orderitemBoarding)
    {
        startPage();
        List<OrderitemBoarding> list = orderitemBoardingService.selectOrderitemBoardingList(orderitemBoarding);
        return getDataTable(list);
    }

    /**
     * 导出值机订单明细列表
     */
    @PreAuthorize(hasPermi = "service:boarding:export")
    @Log(title = "值机订单明细 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderitemBoarding orderitemBoarding) throws IOException
    {
        List<OrderitemBoarding> list = orderitemBoardingService.selectOrderitemBoardingList(orderitemBoarding);
        ExcelUtil<OrderitemBoarding> util = new ExcelUtil<OrderitemBoarding>(OrderitemBoarding.class);
        util.exportExcel(response, list, "值机订单明细 数据");
    }

    /**
     * 获取值机订单明细详细信息
     */
    @PreAuthorize(hasPermi = "service:boarding:query")
    @GetMapping(value = "/{orderitemboardingId}")
    public AjaxResult getInfo(@PathVariable("orderitemboardingId") Long orderitemboardingId)
    {
        return AjaxResult.success(orderitemBoardingService.selectOrderitemBoardingById(orderitemboardingId));
    }

    /**
     * 新增值机订单明细
     */
    @PreAuthorize(hasPermi = "service:boarding:add")
    @Log(title = "值机订单明细 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderitemBoarding orderitemBoarding)
    {
        return toAjax(orderitemBoardingService.insertOrderitemBoarding(orderitemBoarding));
    }

    /**
     * 修改值机订单明细
     */
    @PreAuthorize(hasPermi = "service:boarding:edit")
    @Log(title = "值机订单明细 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderitemBoarding orderitemBoarding)
    {
        return toAjax(orderitemBoardingService.updateOrderitemBoarding(orderitemBoarding));
    }

    /**
     * 删除值机订单明细
     */
    @PreAuthorize(hasPermi = "service:boarding:remove")
    @Log(title = "值机订单明细 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderitemboardingIds}")
    public AjaxResult remove(@PathVariable Long[] orderitemboardingIds)
    {
        return toAjax(orderitemBoardingService.deleteOrderitemBoardingByIds(orderitemboardingIds));
    }

    @PostMapping("/selupdate")
    public AjaxResult selupdate(@RequestParam int count,
                                @RequestParam Long orderBoarding){

        return AjaxResult.success(orderitemBoardingService.updateOrderitemBoardingByStatus(count,orderBoarding));
    }
}
